﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;



namespace GeoWeb.Demo.Commons
{
    using GeoWeb.Common;

    public partial class GeoDirFileHelper_Demo : System.Web.UI.Page
    {
        private string strPath = @"D:\learn\dotnet\commonlibrarynet\branches\CommonLibraryNET_0.9.3\build\_commonlibrary.settings.xml";
        private string directoryPath = "D:\\d";
        private string strToDirectory = "d:\\a";

        protected void Page_Load(object sender, EventArgs e)
        {

              
        }
        #region 文件操作
        private void funfile()
        {
            //是否存在文件
            bool blnIsExistFile = IOHelper.IsExistFile(strPath);
            //创建目录
            bool blnCreateDirectory = IOHelper.CreateDir(strPath);
            //删除文件
            bool blbDel = IOHelper.DeleteFile(strPath);
            //获取文件名
            string strGetFileName = IOHelper.GetFileName(strPath);
            //获取文件名，是否包含后缀
            string strGetFileName2 = IOHelper.GetFileName(strPath, true);
            //获取文件的新名称
            string strGetNewFileFullName = IOHelper.GetNewFileFullName(strPath);
            //获取文件的后缀，包含.
            string strGetFileExtension = IOHelper.GetFileExtension(strPath);
            //打开文件
            bool blnOpenFile = IOHelper.OpenFile(strPath);
            //获取文件大小
            string strGetFileSize = IOHelper.GetFileSize(strPath);
            //打开文字返回数组
            byte[] binFileToStreamByte = IOHelper.FileToStreamByte(strPath);
            //将文件数组写入到文件
            bool blnByteStreamToFile = IOHelper.ByteStreamToFile(IOHelper.GetNewFileFullName(strPath), binFileToStreamByte);
            //读取并写入文件
            IOHelper.ReadAndWriteFile(null, null, null);
            //读取文件，返回文本内容
            string strReadFile = IOHelper.ReadFile(strPath);
            //以utf-8的格式写入文件
            IOHelper.WriteFile(strPath, null);
            //追加字符串到文件中
            IOHelper.ReadAndAppendFile(strPath, null);
            //拷贝文件
            IOHelper.CopyFile(null, null);
            //剪切文件
            IOHelper.MoveFile(null, null);
        }
        #endregion

        #region 目录操作
        private void fundir()
        {
            //获取指定目录的子目录名称
            string[] strGetDirs = IOHelper.GetDirs(directoryPath);
            //创建目录
            bool blnCreateDir = IOHelper.CreateDir(directoryPath);
            //拷贝目录
            bool blnCopyDir = IOHelper.CopyDir(directoryPath, strToDirectory);
            //删除目录
            bool blnDeleteDir = IOHelper.DeleteDir(directoryPath);
            //获取目录下的文件
            string[] strGetDirFiles = IOHelper.GetDirFiles(directoryPath);
            //获取目录下的文件，搜索模式
            strGetDirFiles = IOHelper.GetDirFiles(directoryPath, System.IO.SearchOption.AllDirectories);
            //获取目录下的文件，搜索模式
            strGetDirFiles = IOHelper.GetDirFiles(directoryPath, "中国");
            //目录下是不是为空
            bool blnIsEmptyDirectory = IOHelper.IsEmptyDirectory(directoryPath);
            //判断目下下是否包含文件
            bool blnContainFile = IOHelper.ContainFile(directoryPath, "1.txt", true);
            //设置当前目录
            IOHelper.SetCurrentDirectory(directoryPath);
            //获取当前目录
            string strGetCurrentDirectory = IOHelper.GetCurrentDirectory();
            //获取驱动器
            System.IO.DriveInfo[] strGetAllDrives = IOHelper.GetAllDrives();
        }
        #endregion


        protected void IsExistFile_Click(object sender, EventArgs e)
        {

        }

        protected void CreateDirectory_Click(object sender, EventArgs e)
        {

        }

        protected void DeleteFile_Click(object sender, EventArgs e)
        {

        }

        protected void GetFileName_Click(object sender, EventArgs e)
        {

        }

        protected void GetFileName2_Click(object sender, EventArgs e)
        {

        }

        protected void GetNewFileFullName_Click(object sender, EventArgs e)
        {

        }

        protected void GetFileExtension_Click(object sender, EventArgs e)
        {

        }

        protected void GetFileSize_Click(object sender, EventArgs e)
        {

        }

        protected void FileToStreamByte_Click(object sender, EventArgs e)
        {

        }

        protected void ByteStreamToFile_Click(object sender, EventArgs e)
        {

        }

        protected void ByteStreamToFile2_Click(object sender, EventArgs e)
        {

        }

        protected void ReadAndWriteFile_Click(object sender, EventArgs e)
        {

        }

        protected void ReadFile_Click(object sender, EventArgs e)
        {

        }

        protected void WriteFile_Click(object sender, EventArgs e)
        {

        }

        protected void ReadAndAppendFile_Click(object sender, EventArgs e)
        {

        }

        protected void CopyFile_Click(object sender, EventArgs e)
        {

        }

        protected void MoveFile_Click(object sender, EventArgs e)
        {

        }
    }
}